<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required" lay-reqtext="用户名不能为空" placeholder="请输入用户名" value=""
                   class="layui-input">
            <tip>填写自己管理账号的名称。</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">性别</label>
        <div class="layui-input-block">
            <input type="radio" name="sex" value="男" title="男" checked="">
            <input type="radio" name="sex" value="女" title="女">
            <input type="radio" name="sex" value="保密" title="保密">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">密码</label>
        <div class="layui-input-block">
            <input type="text" name="passwrod" lay-verify="required" lay-reqtext="密码不能为空" placeholder="请输入密码" value=""
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">出生年月</label>
        <div class="layui-input-block">
            <input type="text" name="birthday" id="date1" placeholder="请输入出生年月" lay-verify="date" value=""
                   placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
        </div>
    </div>
    <%--    <div class="layui-inline">--%>
    <%--        <label class="layui-form-label">验证日期</label>--%>
    <%--        <div class="layui-input-inline">--%>
    <%--            <input type="text" name="date" id="date1" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">--%>
    <%--        </div>--%>
    <%--    </div>--%>
    <div class="layui-form-item">
        <label class="layui-form-label">城市</label>
        <div class="layui-input-block">
            <input type="text" name="city" placeholder="请输入城市" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">角色</label>
        <div class="layui-input-block">
            <select name="roleName" lay-verify="required" lay-search="">
                <option value="">请选择</option>
                <option value="1">超级用户</option>
                <option value="2">boss</option>
                <option value="3">Hr人事</option>
                <option value="4">员工</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate,
            $ = layui.$;

        //日期
        laydate.render({
            elem: '#date1'
        });

        //监听提交
        form.on('submit(saveBtn)', function (data) {

            var addData = JSON.stringify(data.field);

            $.ajax({
                type: 'post',
                url: '../add/UserInfo',
                data: addData,
                contentType: 'application/json',
                success: function (data) {
                    // 关闭弹出层
                    let code1 = data.code;

                    if (code1 == 0) {

                        layer.msg("添加成功");
                        parent.location.reload();

                    } else {
                        layer.alert(data.msg, "错误提示");
                    }
                }
            })


        });

    });
</script>
</body>
</html>